import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Controls 2.5 as Control25
import QtQuick.Layouts 1.12

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")
    Image{
        anchors.fill: parent
        source: "qrc:/image/image/25.jpg"
    }
    //==================================================
    //Пример использования сигналов и слотов между С++ и QML
    signal qmlSignal(string sentMsg);
    function qmlSlot(msg){
        console.log("QML received: " + msg);
    }
    //==================================================
    Rectangle{
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter
        width: 140
        height: 174
        color: "#1aae5e"
        border.color: "black"
        border.width: 1
        radius: 10
        Control25.GroupBox {
            hoverEnabled: false
            wheelEnabled: false
            title: qsTr("Выбор источника")
            anchors{
                fill: parent
            }
            ColumnLayout {
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.verticalCenter: parent.verticalCenter
                Control25.RadioButton {
                    id: rbTxt
                    text: qsTr("Txt")
                    checked: true
                }
                Control25.RadioButton {
                    id: rbHtml;
                    text: qsTr("Html")
                }
                Control25.Button{
                    text: qsTr("Показать");
                    onClicked: {
                        if(rbTxt.checked){
                            qmlSignal("TXT");
                        }
                        else if(rbHtml.checked){
                            qmlSignal("HTML");
                        }
                        else{
                            console.log(qsTr("Неверный передаваемый тип"));
                        }
                    }
                }
            }
        }
    }
}
